package com.reportes;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.http.HttpServletRequest;

import com.Reporte;

import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRResultSetDataSource;
import exceptions.InvalidArgumentException;

public class Coejecutora extends Reporte {

	@Override
	public void VerificarParametros(HttpServletRequest request)
			throws InvalidArgumentException {
	}

	@Override
	public Object clone() throws CloneNotSupportedException {
		Coejecutora reporte = new Coejecutora();
		copyAttributesTo(reporte);
		return reporte;
	}

	@Override
	protected JRDataSource executeQuery(Connection connection)
			throws SQLException {
		StringBuffer sql =
			new StringBuffer("SELECT")
					.append(" coejecutora.rif,")
					.append(" coejecutora.nombre,")
					.append(" coejecutora.direccion,")
					.append(" coejecutora.actividad_economica,")
					.append(" coejecutora.telefono,")
					.append(" coejecutora.movil,")
					.append(" coejecutora.fax,")
					.append(" coejecutora.email,")
					.append(" personal.nombre as pnombre,")
					.append(" personal.apellido as papellido,")
					.append(" personal.cedula as pcedula,")
					.append(" personal.telefono as ptelefono,")
					.append(" personal.movil as pmovil,")
					.append(" empleado_coejecutora.cargo as pcargo")
					.append(" FROM")
					.append(" Coejecutora")
					.append(" LEFT JOIN empleado_coejecutora ON (coejecutora_id = coejecutora.id)")
					.append(" INNER JOIN personal ON (empleado_coejecutora.personal_id = personal.id)")
					.append(" ORDER BY coejecutora.nombre,personal.cedula");
		Statement statement = connection.createStatement();
		ResultSet rs = statement.executeQuery(sql.toString());
		return new JRResultSetDataSource(rs);
	}

}
